Add Teredo (RFC4380) embedding strategy#109
Conversation
Greptile SummaryThis PR adds a
Confidence Score: 5/5The change is self-contained and additive — new strategy class, new test data provider, and one new test method; no existing production paths are modified. The Teredo prefix check, XOR extraction, and canonical packing all match RFC 4380 § 4 and are verified against the RFC's own worked example. The bit-flag renumbering in the test interface is safe because every usage references the constants by name. The related ip-doctrine library makes no reference to embedding strategies and is unaffected. No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant Teredo as Strategy\Teredo
participant Binary as Util\Binary
participant MbString as Util\MbString
note over Caller,MbString: isEmbedded - prefix detection
Caller->>Teredo: isEmbedded(binary)
Teredo->>MbString: "getLength(binary) == 16?"
Teredo->>MbString: subString(binary, 0, 4)
Teredo->>Binary: fromHex('20010000')
Teredo-->>Caller: "true if first 4 bytes == 2001:0000"
note over Caller,MbString: extract - client IPv4 recovery
Caller->>Teredo: extract(binary)
Teredo->>MbString: "getLength(binary) == 16?"
Teredo->>MbString: subString(binary, 12, 4)
note right of Teredo: XOR last 4 bytes with 0xFFFFFFFF
Teredo-->>Caller: 4-byte client IPv4
note over Caller,MbString: pack - canonical Teredo construction
Caller->>Teredo: pack(ipv4binary)
Teredo->>MbString: "getLength(ipv4binary) == 4?"
Teredo->>Binary: fromHex('20010000') prefix
Teredo->>Binary: fromHex('0000000000000000') zeroed fields
note right of Teredo: XOR IPv4 with 0xFFFFFFFF
Teredo-->>Caller: 16-byte canonical Teredo address
Reviews (2): Last reviewed commit: "feature(strategy): ✨ add Teredo (RFC4380..." | Re-trigger Greptile |
| Unfortunately there are several different strategies for embedding a version 4 | ||
| address into version 6, so this library offers various strategy implementations | ||
| for the main three: | ||
| for the main three (and one deprecated): |
There was a problem hiding this comment.
The prose says "the main three (and one deprecated)" but the table now has four entries. The parenthetical also never identifies which strategy is deprecated (IPv4-compatible, per RFC 4291 §2.5.5.1). Consider updating the sentence to count accurately and name the deprecated strategy.
| for the main three (and one deprecated): | |
| for four strategies (the IPv4-compatible strategy is deprecated per RFC 4291): |
No description provided.